package com.jakewharton.rxbinding4.component;

import static com.jakewharton.rxbinding4.internal.Preconditions.checkNotNull;

import com.jakewharton.rxbinding4.InitialValueObservable;

import io.reactivex.rxjava3.annotations.NonNull;
import ohos.agp.components.TimePicker;

/**
 * Rx time picker
 */
public class RxTimePicker {
    /**
     * Create an observable of time change events for {@code view}.
     * <p>
     * <em>Warning:</em> Values emitted by this observable contain a <b>mutable</b>
     * {@link CharSequence} owned by the host {@code Text} and thus are <b>not safe</b> to cache
     * or delay reading (such as by observing on a different thread). If you want to cache or delay
     * reading the items emitted then you must map values through a function which calls
     * {@link String#valueOf} or {@link CharSequence#toString() .toString()} to create a copy.
     * <p>
     * <em>Warning:</em> The created observable keeps a strong reference to {@code view}. Unsubscribe
     * to free this reference.
     * <p>
     * <em>Note:</em> A value will be emitted immediately on subscribe.
     *
     * @param view view
     * @return the initial value observable
     */
    @NonNull
    public static InitialValueObservable<TimePickerTimeChangeEvent> timeChangeEvents(@NonNull TimePicker view) {
        checkNotNull(view, "view == null");
        return new TimePickerTimeChangeEventObservable(view);
    }

    private RxTimePicker() {
        throw new AssertionError("No instances.");
    }
}
